home *** CD-ROM | disk | FTP | other *** search
- #include <SpeechRecognition.h>
- #include <stdio.h>
-
- OSErr MyCallPersonInPath (SRPath recognizedPath);
-
- /*
- const char * kPersonNames[] = {"Arlo", "Matt", "Brent", "my wife", NULL};
- */
-
- extern const char * kPersonNames[];
- const char * kPhoneNumbers[] = {"555-4567", "555-4568", "555-4569",
- "(123) 456-7890"};
-
- OSErr MyCallPersonInPath (SRPath recognizedPath)
- {
- OSErr myErr = noErr;
- SRLanguageObject myPersonLM;
-
- /* recognizedPath has two sub-elements: */
- /* "<call>" (SRLanguageModel), "<person>" (SRLanguageModel) */
- /* we get the second sub-element */
- myErr = SRGetIndexedItem (recognizedPath, &myPersonLM, 1);
- if (!myErr) {
- SRLanguageObject myPhraseSpoken;
-
- /* myPersonLM will have one sub-element, the name spoken (a phrase) */
- myErr = SRGetIndexedItem (myPersonLM, &myPhraseSpoken, 0);
- if (!myErr) {
- long myRefCon;
- Size myLen = sizeof (myRefCon);
-
- /* When we built the language model, we set the refcon to the index */
- /* of names in a list. The phone numbers in kPhoneNumbers correspond */
- /* to those names */
- myErr = SRGetProperty (myPhraseSpoken, kSRRefCon, &myRefCon, &myLen);
- if (!myErr) {
- short myArrayIndex = myRefCon;
-
- printf ("Now calling %s. Dialing %s.\n",
- kPersonNames[myArrayIndex], kPhoneNumbers[myArrayIndex]);
- }
-
- /* release myPhraseSpoken when done with it */
- myErr = SRReleaseObject (myPhraseSpoken);
- }
-
- /* release myPersonLM when done with it */
- myErr = SRReleaseObject (myPersonLM);
- }
-
- return myErr;
- }
-
-